pub struct VirtualManifest {
replace: Vec<(PackageIdSpec, Dependency)>,
workspace: WorkspaceConfig,
+ profiles: Profiles,
}
/// General metadata about a package which is just blindly uploaded to the
pub panic: Option<String>,
}
-#[derive(Default, Clone, Debug)]
+#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct Profiles {
pub release: Profile,
pub dev: Profile,
impl VirtualManifest {
pub fn new(replace: Vec<(PackageIdSpec, Dependency)>,
- workspace: WorkspaceConfig) -> VirtualManifest {
+ workspace: WorkspaceConfig,
+ profiles: Profiles) -> VirtualManifest {
VirtualManifest {
replace: replace,
workspace: workspace,
+ profiles: profiles,
}
}
pub fn workspace_config(&self) -> &WorkspaceConfig {
&self.workspace
}
+
+ pub fn profiles(&self) -> &Profiles {
+ &self.profiles
+ }
}
impl Target {
use std::slice;
use core::{Package, VirtualManifest, EitherManifest, SourceId};
-use core::{PackageIdSpec, Dependency};
+use core::{PackageIdSpec, Dependency, Profile, Profiles};
use ops;
use util::{Config, CargoResult, Filesystem, human};
use util::paths;
self.config
}
+ pub fn profiles(&self) -> &Profiles {
+ let root = self.root_manifest.as_ref().unwrap_or(&self.current_manifest);
+ match *self.packages.get(root) {
+ MaybePackage::Package(ref p) => p.manifest().profiles(),
+ MaybePackage::Virtual(ref m) => m.profiles(),
+ }
+ }
+
/// Returns the root path of this workspace.
///
/// That is, this returns the path of the directory containing the
extra);
}
+ if let Some(ref root_manifest) = self.root_manifest {
+ let default_profiles = Profiles {
+ release: Profile::default_release(),
+ dev: Profile::default_dev(),
+ test: Profile::default_test(),
+ test_deps: Profile::default_dev(),
+ bench: Profile::default_bench(),
+ bench_deps: Profile::default_release(),
+ doc: Profile::default_doc(),
+ custom_build: Profile::default_custom_build(),
+ };
+
+ for pkg in self.members().filter(|p| p.manifest_path() != root_manifest) {
+ if pkg.manifest().profiles() != &default_profiles {
+ let message = &format!("profiles for the non root package will be ignored, \
+ specify profiles at the workspace root:\n\
+ package: {}\n\
+ workspace: {}",
+ pkg.manifest_path().display(),
+ root_manifest.display());
+
+ //TODO: remove `Eq` bound from `Profiles` when the warning is removed.
+ try!(self.config.shell().warn(&message));
+ }
+ }
+ }
+
Ok(())
}
}
let resolve = try!(ops::resolve_ws(&mut registry, ws));
let packages = ops::get_resolved_packages(&resolve, registry);
- let profiles = try!(ws.current()).manifest().profiles();
+ let profiles = ws.profiles();
let host_triple = try!(opts.config.rustc()).host.clone();
let mut cx = try!(Context::new(ws, &resolve, &packages, opts.config,
BuildConfig {
bail!("jobs must be at least 1")
}
- let profiles = root_package.manifest().profiles();
+ let profiles = ws.profiles();
if spec.len() == 0 {
try!(generate_targets(root_package, profiles, mode, filter, release));
}
platform: None,
layout: layout,
}));
+ let profiles = build_profiles(&self.profile);
let workspace_config = match self.workspace {
Some(ref config) => {
WorkspaceConfig::Root { members: config.members.clone() }
bail!("virtual manifests must be configured with [workspace]");
}
};
- Ok((VirtualManifest::new(replace, workspace_config), nested_paths))
+ Ok((VirtualManifest::new(replace, workspace_config, profiles), nested_paths))
}
fn replace(&self, cx: &mut Context)
prefix = env::consts::DLL_PREFIX,
suffix = env::consts::DLL_SUFFIX)));
}
+
+#[test]
+fn profile_in_non_root_manifest_triggers_a_warning() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+
+ [workspace]
+ members = ["bar"]
+
+ [profile.dev]
+ debug = false
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .file("bar/Cargo.toml", r#"
+ [project]
+ name = "bar"
+ version = "0.1.0"
+ authors = []
+ workspace = ".."
+
+ [profile.dev]
+ opt-level = 1
+ "#)
+ .file("bar/src/main.rs", "fn main() {}");
+ p.build();
+
+ assert_that(p.cargo_process("build").cwd(p.root().join("bar")).arg("-v"),
+ execs().with_status(0).with_stderr("\
+[WARNING] profiles for the non root package will be ignored, specify profiles at the workspace root:
+package: [..]
+workspace: [..]
+[COMPILING] bar v0.1.0 ([..])
+[RUNNING] `rustc [..]`
+[FINISHED] debug [unoptimized] target(s) in [..]"));
+}
+
+#[test]
+fn profile_in_virtual_manifest_works() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [workspace]
+ members = ["bar"]
+
+ [profile.dev]
+ opt-level = 1
+ debug = false
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .file("bar/Cargo.toml", r#"
+ [project]
+ name = "bar"
+ version = "0.1.0"
+ authors = []
+ workspace = ".."
+ "#)
+ .file("bar/src/main.rs", "fn main() {}");
+ p.build();
+
+ assert_that(p.cargo_process("build").cwd(p.root().join("bar")).arg("-v"),
+ execs().with_status(0).with_stderr("\
+[COMPILING] bar v0.1.0 ([..])
+[RUNNING] `rustc [..]`
+[FINISHED] debug [optimized] target(s) in [..]"));
+}